using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Markup;
using System.Windows.Media.Animation;
namespace Coding4Fun.Phone.Controls
{
	[ContentProperty("Content")]
	public class ProgressOverlay : Control
	{
		private const string string_0 = "fadeIn";
		private const string string_1 = "fadeOut";
		private const string string_2 = "LayoutGrid";
		private Storyboard storyboard_0;
		private Storyboard storyboard_1;
		private Grid grid_0;
		public static readonly DependencyProperty ProgressControlProperty = DependencyProperty.Register("ProgressControl", typeof(object), typeof(ProgressOverlay), new PropertyMetadata(null));
		public static readonly DependencyProperty ContentProperty = DependencyProperty.Register("Content", typeof(object), typeof(ProgressOverlay), new PropertyMetadata(null));
		public object ProgressControl
		{
			get
			{
				return base.GetValue(ProgressOverlay.ProgressControlProperty);
			}
			set
			{
				base.SetValue(ProgressOverlay.ProgressControlProperty, value);
			}
		}
		public object Content
		{
			get
			{
				return base.GetValue(ProgressOverlay.ContentProperty);
			}
			set
			{
				base.SetValue(ProgressOverlay.ContentProperty, value);
			}
		}
		public ProgressOverlay()
		{
			base.set_DefaultStyleKey(typeof(ProgressOverlay));
		}
		public override void OnApplyTemplate()
		{
			base.OnApplyTemplate();
			this.storyboard_0 = (base.GetTemplateChild("fadeIn") as Storyboard);
			this.storyboard_1 = (base.GetTemplateChild("fadeOut") as Storyboard);
			this.grid_0 = (base.GetTemplateChild("LayoutGrid") as Grid);
			if (this.storyboard_1 != null)
			{
				this.storyboard_1.add_Completed(new EventHandler(this.storyboard_1_Completed));
			}
		}
		private void storyboard_1_Completed(object sender, EventArgs e)
		{
			this.grid_0.set_Opacity(1.0);
			base.set_Visibility(1);
		}
		public void Show()
		{
			if (this.storyboard_0 == null)
			{
				base.ApplyTemplate();
			}
			base.set_Visibility(0);
			if (this.storyboard_1 != null)
			{
				this.storyboard_1.Stop();
			}
			if (this.storyboard_0 != null)
			{
				this.storyboard_0.Begin();
			}
		}
		public void Hide()
		{
			if (this.storyboard_1 == null)
			{
				base.ApplyTemplate();
			}
			if (this.storyboard_0 != null)
			{
				this.storyboard_0.Stop();
			}
			if (this.storyboard_1 != null)
			{
				this.storyboard_1.Begin();
			}
		}
	}
}
